package interview.Datastructures;

class Queue{
	private  Node first, last;
	
	public  void enqueue(int num){
		Node queueNode = new Node();
		queueNode.data=num;
		queueNode.next=null;
		
		if (isEmpty()){
			first=last=queueNode;
		}
		else{
			last.next=queueNode;
			last=queueNode;
		}
	}
	public  int dequeue(){
		if(isEmpty())
			return 0;
		else{
			int ret = first.data;
			first=first.next;
			return ret;
		}
	}
	
	public  boolean isEmpty(){
		return (first==null);
	}
}

public class QueueTest {

	public static void main(String[] args) {
		Queue queue = new Queue();
		for(int i=1;i<=5;i++){
			int num = Input.getIntInput();		
			queue.enqueue(num);			
		}
		System.out.println(queue.dequeue());
	}

}
